<?php
namespace App;
use DB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent;
class Admin extends Model{
	//添加用户
	function reg($username,$password){
		$res=DB::table('user')->insert(['username'=>$username,'password'=>$password]);
		return $res;
	}
	//登录
	function login($username,$password){
		$user =DB::table('user')->where('username',"$username")->first();
		if($user){	
			if($user->password==$password){
				$username=session()->put('username', "$username");
				return $username;	
			}else{
				echo "密码错误";die;
			}
		}else{
			echo "没有此用户";
		}
	}
}